home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / examples / misc / wexmast / wbitmap.pro < prev    next >
Text File  |  1997-07-08  |  7KB  |  168 lines

  1. ; $Id: wbitmap.pro,v 1.3 1997/01/15 04:29:15 ali Exp $
  2. ;
  3. ; Copyright (c) 1993-1997, Research Systems, Inc.  All rights reserved.
  4. ;       Unauthorized reproduction prohibited.
  5.  
  6. ; This is the code for a simple bitmapped button. When the
  7. ; button in this example is pressed, the word 'OUCH!' is 
  8. ; printed in the IDL window.
  9.  
  10. ; Bitmap buttons can be used any place that regular buttons
  11. ; are used.  Use bitmap buttons to add variety and personality
  12. ; to your widget applications.
  13.  
  14. ; The VALUE of a bitmapped button is the bitmap
  15. ; to be displayed.  Changing the VALUE of a bitmap button
  16. ; causes the new bitmap to be displayed.
  17.  
  18. ; The procedure WORLDROT.PRO, available from the 'Simple Widget
  19. ; Examples' widget by selecting 'World Rotation Tool', uses bitmap
  20. ; buttons as "action" buttons.
  21.  
  22. ; The procedure SLOTS.PRO, available from the 'Simple Widget 
  23. ; Examples' widget by selecting 'Slot Machine Demo', uses bitmap
  24. ; buttons to display little bitmap pictures that simulate the 
  25. ; wheels of a slot machine.  When selected, the buttons
  26. ; don't actually do anything.   
  27.  
  28.  
  29. PRO wbitmap_event, event 
  30. ; This procedure is the event handler for the 'wbitmap' procedure.
  31.  
  32. ; When a widget is 'touched', put its User Value into the variable 'eventval':
  33.  
  34. WIDGET_CONTROL, event.id, GET_UVALUE = eventval
  35.  
  36. ; This CASE statement branches based on the value of 'eventval'.
  37. ; For a more elaborate example of managing buttons that perform an 
  38. ; action when pressed, see the WBUTTONS.PRO procedure.
  39.  
  40. CASE eventval OF
  41.     "LOOK":print, 'OUCH!'    ;Print OUCH! in the IDL window when the button
  42.                 ;is pressed.
  43. ENDCASE
  44.  
  45. END
  46.  
  47.  
  48.  
  49. PRO wbitmap, GROUP = GROUP
  50. ; This is the procedure that creates a bitmap button widget.
  51.  
  52. ; Create the main, top-level base:
  53.  
  54. base = WIDGET_BASE(TITLE = 'Bitmap Button Example', /COLUMN, XSIZE = 300)
  55.  
  56. ; Create a sub-base to hold the button widget.  The button could be put 
  57. ; directly into the top-level base, but we wanted to show that widget
  58. ; bases can be put inside other widget bases. Also, to make this demo
  59. ; work with both OPEN LOOK and MOTIF, we need to determine which version
  60. ; we are using and, for OPEN LOOK, make the base EXCLUSIVE to properly
  61. ; display the bitmapped button.  Unless you routinely work with BOTH 
  62. ; environments, you shouldn't have to the IF... THEN part the the next
  63. ; command.  Just use the code for OPEN LOOK or MOTIF, depending upon 
  64. ; which toolkit you use:
  65.  
  66.  
  67. VERSION    = WIDGET_INFO(/VERSION)
  68. IF (VERSION.STYLE EQ 'OPEN LOOK') THEN $
  69.     holder = WIDGET_BASE(base, $
  70.                      /FRAME, $
  71.                  /EXCLUSIVE) $    ;If running under OPEN LOOK,
  72.                         ;make the base EXCLUSIVE.
  73. ELSE $
  74.     holder = WIDGET_BASE(base, /FRAME)    ;If running under MOTIF, 
  75.                         ;DON'T make the base EXCLUSIVE.
  76.  
  77. ; The bitmap for the LOOK! button was created with the procedure XBM_EDIT.
  78. ; The bitmap was saved as an "IDL array definition file" and imported into
  79. ; this file with a text editor.
  80. ; Here is the definition of the LOOK! button:
  81.     
  82. looker =     [                $
  83.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  84.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  85.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  86.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  87.         [000B, 000B, 030B, 060B, 000B, 000B, 000B, 000B],$
  88.         [000B, 000B, 033B, 066B, 000B, 000B, 000B, 000B],$
  89.         [000B, 128B, 032B, 065B, 000B, 000B, 000B, 000B],$
  90.         [000B, 128B, 032B, 065B, 000B, 000B, 000B, 000B],$
  91.         [000B, 128B, 032B, 065B, 000B, 000B, 000B, 000B],$
  92.         [000B, 128B, 039B, 079B, 000B, 000B, 000B, 000B],$
  93.         [000B, 128B, 039B, 079B, 000B, 000B, 000B, 000B],$
  94.         [000B, 128B, 039B, 079B, 000B, 000B, 000B, 000B],$
  95.         [000B, 128B, 039B, 079B, 000B, 000B, 000B, 000B],$
  96.         [000B, 128B, 039B, 079B, 000B, 000B, 000B, 000B],$
  97.         [000B, 128B, 032B, 065B, 000B, 000B, 000B, 000B],$
  98.         [000B, 128B, 032B, 065B, 000B, 000B, 000B, 000B],$
  99.         [000B, 128B, 016B, 033B, 000B, 000B, 000B, 000B],$
  100.         [000B, 000B, 015B, 030B, 000B, 000B, 000B, 000B],$
  101.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  102.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  103.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  104.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  105.         [000B, 128B, 000B, 032B, 000B, 000B, 000B, 000B],$
  106.         [000B, 128B, 000B, 032B, 000B, 000B, 000B, 000B],$
  107.         [000B, 128B, 000B, 016B, 000B, 000B, 000B, 000B],$
  108.         [000B, 000B, 001B, 016B, 000B, 000B, 000B, 000B],$
  109.         [000B, 000B, 001B, 008B, 000B, 000B, 000B, 000B],$
  110.         [000B, 000B, 002B, 008B, 000B, 000B, 000B, 000B],$
  111.         [000B, 000B, 002B, 006B, 000B, 000B, 000B, 000B],$
  112.         [000B, 000B, 252B, 003B, 000B, 000B, 000B, 000B],$
  113.         [000B, 000B, 248B, 001B, 000B, 000B, 000B, 000B],$
  114.         [000B, 000B, 224B, 000B, 000B, 000B, 000B, 000B],$
  115.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  116.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  117.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  118.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  119.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  120.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  121.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  122.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  123.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  124.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  125.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  126.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  127.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  128.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  129.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  130.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  131.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  132.         [056B, 192B, 135B, 143B, 195B, 057B, 000B, 000B],$
  133.         [056B, 224B, 207B, 159B, 195B, 057B, 000B, 000B],$
  134.         [056B, 224B, 207B, 159B, 227B, 057B, 000B, 000B],$
  135.         [056B, 224B, 206B, 157B, 243B, 056B, 000B, 000B],$
  136.         [056B, 224B, 206B, 157B, 059B, 056B, 000B, 000B],$
  137.         [056B, 224B, 206B, 157B, 031B, 056B, 000B, 000B],$
  138.         [056B, 224B, 206B, 157B, 031B, 056B, 000B, 000B],$
  139.         [056B, 224B, 206B, 157B, 027B, 056B, 000B, 000B],$
  140.         [056B, 224B, 206B, 157B, 051B, 056B, 000B, 000B],$
  141.         [056B, 224B, 207B, 157B, 227B, 000B, 000B, 000B],$
  142.         [248B, 231B, 207B, 159B, 195B, 057B, 000B, 000B],$
  143.         [248B, 231B, 207B, 159B, 195B, 057B, 000B, 000B],$
  144.         [248B, 199B, 135B, 143B, 195B, 057B, 000B, 000B],$
  145.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B],$
  146.         [000B, 000B, 000B, 000B, 000B, 000B, 000B, 000B]$
  147.         ]
  148.  
  149. ; Making the button appear is rather easy:
  150.  
  151. look = WIDGET_BUTTON(holder, $        ;The button belongs to the base 'holder'.
  152.              VALUE = looker, $    ;The button's value is the bitmap 'looker'.
  153.              UVALUE = "LOOK")    ;Give the button the User Value 'LOOK'.
  154.  
  155. ; Realize the widgets:
  156.  
  157. WIDGET_CONTROL, base, /REALIZE
  158.  
  159. ; Hand off to the XMANAGER:
  160.  
  161. XMANAGER, "wbitmap", base, GROUP_LEADER = GROUP, /NO_BLOCK
  162.  
  163. END
  164.  
  165.  
  166.  
  167.  
  168.